Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add safety check to hwmon read #3134

Merged
merged 1 commit into from
Sep 30, 2024
Merged

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Sep 25, 2024

Avoid panic for accessing slice out of range in hwmon.

Fixes: #3108

@SuperQ SuperQ marked this pull request as ready for review September 25, 2024 22:01
@dswarbrick
Copy link
Contributor

I think it would be helpful to include the value of n in the error message, because "failed to read file: foo" is pretty generic and vague. Either include the specific value of n, or clarify that the reason for failure is that the read returned a negative count - otherwise this will just get lost in the noise when it (hopefully rarely) fails.

Avoid panic for accessing slice out of range in hwmon.

Fixes: #3108

Signed-off-by: Ben Kochie <superq@gmail.com>
Copy link
Contributor

@dswarbrick dswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM.

@discordianfish discordianfish merged commit 1b332ed into master Sep 30, 2024
8 checks passed
@discordianfish discordianfish deleted the superq/hwmon_safe_read branch September 30, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants